package wyp.library.tools;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;

public class WypExternalAppTool {

	public static void openSinaWeibo(Activity __activity, String __url) {
		WypHttpTool.openUrl4Browser(__activity, __url);
	}

	public static void openWeiXin(Activity __activity, String __url) {
		try {
			Intent __intent = new Intent(Intent.ACTION_VIEW);
			__intent.setPackage("com.tencent.mm");// 直接打开微信
			__intent.putExtra(Intent.EXTRA_SUBJECT, "share");
			__intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			__intent.setData(Uri.parse(__url));
			__activity.startActivity(__intent);
		} catch (SecurityException e) {
			Intent __intent = new Intent();
			ComponentName __cmp = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI");
			__intent.setAction(Intent.ACTION_MAIN);
			__intent.addCategory(Intent.CATEGORY_LAUNCHER);
			__intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			__intent.setComponent(__cmp);
			__activity.startActivity(__intent);
		}
	}
}
